package cn.kgc.vue.config;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 课工场
 * @date 2024/7/2
 * @description
 */
@Configuration
@EnableSwagger2
public class Swagger2WebConfig {

    // 设置那些接口需要生成接口文档
    @Bean
    public Docket  docket(){

       return new Docket(DocumentationType.SWAGGER_2)
                //  设置组信息
               .groupName("Java2424")
                //  设置接口文档首页信息
               .apiInfo(apiInfo())
               .select()
               .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
               .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
               .build();
    }

    public ApiInfo apiInfo(){

        return   new ApiInfoBuilder()
                .title("Java2424前后端分离项目技术接口文档")
                .version("1.0")
                .description("该项目是一个前后端分离项目主要使用的技术栈有如下几个:<br/>" +
                        "前端技术栈：Vue+ElementUI+Axios<br/>" +
                        "后端技术栈:springboot+mybatis-plus+shiro+mysql+redis+swagger")
                .build();
    }

}
